package com.example.workone;

import androidx.appcompat.app.AppCompatActivity;

import android.annotation.SuppressLint;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.view.Gravity;
import android.view.View;
import android.widget.Button;
import android.widget.GridLayout;
import android.widget.ImageView;

import java.util.Timer;
import java.util.TimerTask;

public class UC5 extends AppCompatActivity {
    private GridLayout layout;
    private Button btnReturn;
    String[] chars = new String[] {
            "1","2","3",
            "4","5","6",
            "7","8","9",
            "0","+","-",
            "*","/","="
    };
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_uc5);
        layout = findViewById(R.id.view);
        btnReturn = findViewById(R.id.btn1);

        for(int i=0;i<chars.length;i++ )
        {
            Button btn = new Button(this);
            btn.setText(chars[i]);
            btn.setPadding(160,150,160,150);
            GridLayout.Spec rowSpec = GridLayout.spec (i/3);
            GridLayout.Spec columnSpec = GridLayout.spec(i%3);
            GridLayout.LayoutParams params = new GridLayout.LayoutParams(rowSpec,columnSpec);
            params.setGravity(Gravity.FILL);
            layout.addView(btn,params);
        }

        btnReturn.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                //跳转到UC1
                Intent intent = new Intent(UC5.this, MainActivity.class);
                startActivity(intent);
            }
        });
    }

}

